package t01;

import java.util.Random;

public class FiveInARow {
    public static void FiveInARow() {
        Random random = new Random();
        final char BLACK_CHESS = '\u25CF';// 黑球
        final char WHITE_CHESS = '\u25CB';// 白球
        final char BLANK = '\u253c';//'+'符号，表示无棋子
        char[][] board = new char[15][15];
        int totalMoves = 0;// 记录下了几次棋
        int maxMoves = 15 * 15;// 最大下棋次数
        // 初始化棋盘
        for (int i = 0; i < 15; i++) {
            for (int j = 0; j < 15; j++) {
                board[i][j] = BLANK;
            }
        }
        while (totalMoves < maxMoves) {
            int x = random.nextInt(15);// 0-14之间的随机数，指定数组下标
            int y = random.nextInt(15);
            if (board[x][y] == BLANK) {
                //1：黑棋  2：白棋
                board[x][y] = totalMoves % 2 == 0 ? BLACK_CHESS : WHITE_CHESS;
                totalMoves++;
            }
        }
        for (int i = 0; i < 15; i++) {
            for (int j = 0; j < 15; j++) {
                System.out.print(board[i][j] + "\t");
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        FiveInARow();
    }
}